package service;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import dao.UserClickCountDao;
import dao.impl.UserClickCountDaoImpl;
import domain.UserClickCount;

import java.util.List;

public class UserClickCountService {
    String valueAsString = null;
    private UserClickCountDao contacts = new UserClickCountDaoImpl();
    public String ToJson(UserClickCount userClickCount) {
        int adid = userClickCount.getAdid();
        List<UserClickCount> list = contacts.SelectSumClickCount(adid);
        ObjectMapper objectMapper = new ObjectMapper();
        try {
            valueAsString = objectMapper.writeValueAsString(list);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        }
        return valueAsString;
    }
}
